package com.yujistu.global;

import com.yujistu.integration.result.LoginResult;

import javax.microedition.khronos.opengles.GL10;

/**
 * Created by Win on 2015/11/13.
 */
public class GlobalContext {

    private static GlobalContext  context;
    private LoginResult login;

    // 采用双重检查加锁实例化单件
    public static GlobalContext  getInstance(){
        // 第一次检查
        if(null == context){
            synchronized (GlobalContext.class){
                // 第二次检查
                if(null == context){
                    context = new GlobalContext();
                }
            }
        }
        return context;
    }

     /* 判断用户是否登录 */
    public boolean isLoginResult(){
        if(getInstance().getLogin() == null){
            return false;
        }
        if(getInstance().getLogin().getData() == null){
            return false;
        }
        if(getInstance().getLogin().getToken() == null){
            return false;
        }
        return true;
    }

    public LoginResult getLogin() {
        return login;
    }

    public void setLogin(LoginResult login) {
        this.login = login;
    }
}
